home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
Dots & Pixels
/
sources
/
stopwatch.cp
< prev
next >
Wrap
Text File
|
1995-09-29
|
949b
|
59 lines
#include <Timer.h>
#include "stopwatch.h"
const long stopwatch::starting_value = 0x80000000; // max # of microseconds
stopwatch::stopwatch()
{
tmAddr = 0; // no Task
tmWakeUp = 0; // see IM VI 23-7 'you should set tmWakeUp and tmReserved to zero
tmReserved = 0; // when you first install an extended Time Manager task.
InsXTime( (QElem *)(TMTask *)this);
running = false;
}
stopwatch::~stopwatch()
{
if( running)
{
(void)stop();
}
};
long stopwatch::read()
{
long result = 0;
if( running)
{
result = stop();
InsXTime( (QElem *)(TMTask *)this);
restart( 0);
}
return result;
}
long stopwatch::stop()
{
long result = 0;
if( running)
{
RmvTime( (QElem *)(TMTask *)this);
running = false;
if( tmCount != 0)
{
result = tmCount - starting_value;
}
}
return result;
}
void stopwatch::restart( unsigned long to_go)
{
if( !running)
{
PrimeTime( (QElem *)(TMTask *)this, to_go);
running = true;
}
}